<include file="Public/head" />
<style type="text/css">
    .new_chip_btn{width:80px;border-radius: 3px;color: #fff;margin-left: 7px;padding: 0;
        background-color: #20ab4f;border: medium none;}
    .focus-btn {
    width: 80px;
    border-radius: 3px;
    color: #fff;
    margin-left: 7px;
    padding: 0;
    background-color: #20ab4f;
    border: medium none;
}
</style>
</head>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar"  menu="clcwht.clcwspgl" />

    <div class="mianR">
        <h3 class="cha" style="margin-bottom: 0px;">碎片管理</h3>
        
        <div style="float:left;width:100%;text-align: left;height:30px;padding-top: 8px;">

            <input type="text" name="name" placeholder="请输入标识" />
            <input type="text" name="desc" placeholder="请输入描述" />
            <input type="button" value="查询" name="focus_search" class="focus-btn"  />

            <input type="button" value="新建碎片" id="create_new_chip" class="new_chip_btn" style="float:right;padding: 2px;"/>
        </div>
        <div class="yuList">
            <div class="listBox" id="listBox"></div>
        </div>
    </div>
    <div class="clear"></div>
    <script type="text/javascript">
        //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null)
                return unescape(r[2]);
            return null; //返回参数值
        }

        function get_list() {
            var url = mkUrl();
            var p = getUrlParam('p');
            if (p != null) {
                var purl = "?p=" + p;
            } else {
                var purl = "?p=1";
            }
            $.get("/ClcwChip/clcwChipList/"+ purl, url, function (data) {
                $("#listBox").html(data);
            }, "html");
        }
        function get_page(p) {
            var url = mkUrl();
            $.get("/ClcwChip/clcwChipList/"+ encodeURI("p/" + p), url, function (data) {
                $("#listBox").html(data);
            }, "html");
        }
        get_list();

        $("input[name='focus_search']").click(function () {
            get_list();
        });

        function mkUrl() {
            var url = "";
            var name = $("input[name='name']").val();
            var desc = $("input[name='desc']").val();
            if (name) {
                url += '&name=' + name;
            }
            if (desc) {
                url += '&desc=' + desc;
            }
            return url;
        }

        $(".new_chip_btn").on('click',function () {
            window.location.href= "/ClcwChip/addClcwChip";
        });
        
    </script>
    <include file="Public/foot" />
